<template>
  <el-dialog
    :close-on-click-model="clickClose"
    :title="title"
    :visible.sync="visible"
  >
    <slot></slot>
    <div slot="footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button :logding="confirmLoading" @click="$emit('confirm')"
        >确认</el-button
      >
    </div>
  </el-dialog>
</template>
<script>
export default {
  name: "MyDialog",
  data() {
    return {
      /**
       * 是否显示
       */
      visible: false,

      /**
       * 提交loading
       */
      confirmLoading: false,
    };
  },
  methods: {
    /**
     * 显示
     */
    show() {
      this.visible = true;
    },

    /**
     * 隐藏
     */
    hide() {
      this.visible = false;
    },

    /**
     *开始loading
     */
    start() {
      this.confirmLoading = true;
    },
    /**
     *结束loading
     */
    stop() {
      this.confirmLoading = false;
    },
  },
  props: {
    /**
     * 标题
     */
    title: String,

    /**
     * 点击遮罩关闭
     */
    clickClose: Boolean,
  },
};
</script>